package com.shenfa.dao;

import java.sql.SQLException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.shenfa.bean.CostPar;

/**
 * 计费信息数据库操作类
 * 
 * @author yanglong
 * 
 * @date 2011-8-23
 *
 */
public class CostParDao {
	
	@Autowired
	private SqlMapClient sqlMapClient;
	
	/**
	 * 根据对象条件查询计费列表
	 * 
	 * @return	计费列表
	 */
	@SuppressWarnings("unchecked")
	public List<CostPar> getList(CostPar t, int start, int limit) {
		List<CostPar> list = null;
		try {
			list = sqlMapClient.queryForList("costpar_manager.getList", t, start, limit);
		} catch (SQLException e) {
			e.printStackTrace();
			return null;
		}
		return list;
	}
	public int queryCount(CostPar t) {
		int a;
		try {
			a = (Integer)sqlMapClient.queryForObject("costpar_manager.getCount", t);
		} catch (SQLException e) {
			e.printStackTrace();
			return -1;
		}
		return a;
	}

	/**
	 * 添加计费信息
	 * @param t
	 * @return
	 */
	public int add(CostPar t) {
		try {
			sqlMapClient.insert("costpar_manager.add", t);
			return 0;
		} catch (SQLException e) {
			e.printStackTrace();
			return -1;
		}
	}

	/**
	 * 删除计费信息
	 * @param t
	 * @return
	 */
	public int del(CostPar t) {
		try {
			sqlMapClient.delete("costpar_manager.del", t);
			return 0;
		} catch (SQLException e) {
			e.printStackTrace();
			return -1;
		}
	}

	/**
	 * 更新计费信息
	 * @param t
	 * @return
	 */
	public int upd(CostPar t) {
		int i=0;
		try {
			i=sqlMapClient.update("costpar_manager.upd", t);
			return i;
		} catch (SQLException e) {
			e.printStackTrace();
			return -1;
		}
	}

}
